package com.abc.cloud.controller;

import com.abc.cloud.common.utils.Result;
import com.abc.cloud.common.utils.UserHolder;
import com.abc.cloud.dto.count.DashBoardCount;
import com.abc.cloud.dto.count.UserFileCount;
import com.abc.cloud.service.CountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "统计接口")
@RestController
@RequestMapping("/count")
public class CountController {

    @Autowired
    private CountService countService;

    @ApiOperation("后台桌面统计")
    @GetMapping("/admin/dashboard")
    public Result<DashBoardCount> getDashboardCount(){
        DashBoardCount dashBoardCount = countService.getDashboardCount();

        return Result.success(dashBoardCount, "获取成功");
    }

    @ApiOperation("用户文件统计")
    @GetMapping("/user/fileCount")
    public Result<List<UserFileCount>> getUserFileCount(){
        Long userId = UserHolder.getUser().getId();
        List<UserFileCount> userFileCount = countService.getUserFileCount(userId);

        return Result.success(userFileCount, "获取成功");
    }

}
